"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
/**
 * 装饰器:装饰器是一-种特殊类型的声明， 它能够被附加到类声明，方法,属性上,可以为原本的代码添加额外的功能。
    通俗的讲装饰器就是一个函数，可以注入到类、方法、属性参数上来扩展类、属性、方法的功能。
    常见的装饰器有:类装饰器、属性装饰器、方法装饰器
    装饰器的写法:普通装饰器(无传参) -、装饰器工厂(可传参)
    装饰器是过去几年中js最大的成就之一。

 */
//装饰器就是一个函数
{
    var classDes = function (p) {
        console.log(p, 'p');
        var t = new p();
        console.log(t.name);
    };
    var Person_1 = /** @class */ (function () {
        function Person() {
            this.name = '张三';
        }
        Person = __decorate([
            classDes
        ], Person);
        return Person;
    }());
    var classDes1 = function (p) {
        return function (target) {
            console.log(p, target); //p 参数 target 装饰器的类
        };
    };
    //属性装饰器
    var proDes = function (p) {
        return function (target, attr) {
            console.log(p, 'p');
            console.log(target, 'target');
            console.log(attr, 'attr');
            console.log(target[attr], 'target[attr]');
        };
    };
    //方法装饰器
    var fnDes_1 = function (p) {
        return function (target, methodName, desc) {
            console.log(p, 'p----------------------------------');
            console.log(target, 'target');
            console.log(methodName, 'methodName');
            console.log(desc.value(1, 2), 'desc');
        };
    };
    var Person1 = /** @class */ (function () {
        function Person1() {
            this.name = '张三';
            this.age = 20;
        }
        Person1.prototype.sum = function (num1, num2) {
            return num1 + num2;
        };
        __decorate([
            proDes('参数')
        ], Person1.prototype, "age", void 0);
        __decorate([
            fnDes_1('456')
        ], Person1.prototype, "sum", null);
        Person1 = __decorate([
            classDes1('66666')
        ], Person1);
        return Person1;
    }());
    var p = new Person1();
    console.log(p.age, 'p.age');
}
